<?php

use Illuminate\Support\Facades\Route;
/**
 * 
 * @author hg <364825702@qq.com>
 * 商城App端 路由
 * 
 */
Route::namespace('App')->prefix('App')->group(function(){
    Route::post('/login',[App\Http\Controllers\App\LoginController::class,'login']); // 登陆
    Route::post('/auth_login','LoginController@auth_login'); // 微信登录
    Route::post('/register',[App\Http\Controllers\App\LoginController::class,'register']); // 注册
    Route::post('/forget_password','LoginController@forget_password'); // 忘记密码
    Route::get('/logout',[App\Http\Controllers\App\LoginController::class,'logout']); // 退出账号
    Route::get('/check_login',[App\Http\Controllers\App\LoginController::class,'check_login']); // 检测登陆
    Route::post('/send_sms',[App\Http\Controllers\App\LoginController::class,'send_sms']); // 发送短信

    Route::get('/index',[App\Http\Controllers\App\IndexController::class,'app_base']); // 首页数据
    Route::get('/goods_classes/get_goods_classes',[App\Http\Controllers\App\GoodsClassController::class,'get_goods_classes']); // 获取栏目信息
    Route::get('/goods_classes/get_goods_class_children/{id}',[App\Http\Controllers\App\GoodsClassController::class,'get_goods_class_children']); // 获取栏目信息2
    Route::get('/stores/get_stores',[App\Http\Controllers\App\StoreController::class,'get_stores']); // 获取店铺列表
    Route::get('/store/{id}',[App\Http\Controllers\App\StoreController::class,'get_store_info']); // 店铺首页

    Route::get('/goods/goods_info/{id}',[App\Http\Controllers\App\GoodsController::class,'goods_info']); // 获取商品详情
    Route::get('/goods/comment_statistics/{id}',[App\Http\Controllers\App\GoodsController::class,'goods_comment_statistics']); // 获取商品评论统计
    Route::get('/goods/comments/{id}',[App\Http\Controllers\App\GoodsController::class,'goods_comments']); // 获取商品评论列表
    Route::post('/goods/search/all',[App\Http\Controllers\App\GoodsController::class,'goods_search']); // 搜索商品列表

    // 积分商城
    Route::get('/integral',[App\Http\Controllers\App\IntegralController::class,'index']); // 首页数据
    Route::get('/integral/goods_class',[App\Http\Controllers\App\IntegralController::class,'get_integral_class']); // 积分商品分类
    Route::post('/integral/pay',[App\Http\Controllers\App\IntegralController::class,'pay']); // 积分商品支付


    // 收藏/关注
    Route::get('/is_fav',[App\Http\Controllers\App\FavoriteController::class,'is_fav']);

    // 购物车
    Route::get('/carts/cart_count',[App\Http\Controllers\App\CartController::class,'cart_count']); // 获取购物车商品数量

    // 秒杀页面
    Route::get('/seckills','SeckillController@index'); // 首页数据

    Route::group(['middleware'=>'auth:users'],function(){

        // 用户资料
        Route::get('/users/info','UserController@user_info'); // 获取用户资料
        Route::match(['get','put'],'/users/edit_user','UserController@edit_user'); // 修改用户资料
        Route::post('/users/avatar_upload','UserController@avatar_upload'); // 用户头像上传

        Route::get('money_logs', [App\Http\Controllers\App\MoneyLogController::class,'index']);// 资金变动
        Route::apiResource('cashes','CashController')->except(['update','show','destroy']);// 资金提现
        Route::get('cashes/show','CashController@show'); // 获取提现信息

        // 用户认证
        Route::get('/users/user_check','UserCheckController@user_check'); // 获取用户认证资料
        Route::post('/users/edit_user_check','UserCheckController@edit_user_check'); // 修改用户认证资料
        Route::post('/users/user_check_upload','UserCheckController@user_check_upload'); // 用户认证图片上传


        // 购物车
        Route::resource('carts',Http\Controllers\App\CartController::class)->except(['show']);

        // 优惠券
        Route::get('/coupons','CouponController@index'); // 优惠券列表
        Route::post('/coupons/receive','CouponController@receive_coupon'); // 领取优惠券

        // 收藏/关注
        Route::resource('favorites',Http\Controllers\App\FavoriteController::class)->except(['update','show']);

        // 订单列表
        Route::get('/order','OrderController@get_orders'); // 获取订单列表

        // 订单处理
        Route::get('/order/create_order_before','OrderController@create_order_before'); // 生成订单前处理
        Route::get('/order/create_order_after','OrderController@create_order_after'); // 生成订单后处理
        Route::post('/order/create_order','OrderController@create_order'); // 生成订单
        Route::post('/order/pay','OrderController@pay'); // 订单支付
        Route::put('/order/edit_order_status','OrderController@edit_order_status'); // 取消订单
        Route::get('/order/get_order_info/{id}','OrderController@get_order_info'); // 查看订单信息

        // 评论管理
        Route::apiResource('order_comments','OrderCommentController')->except(['destroy']);
        Route::post('/order_comments/thumb/upload','OrderCommentController@comment_upload'); // 评论管理图片上传

        // 订单售后
        Route::apiResource('refunds','RefundController')->except(['index','destroy']);

        // 分销日志
        Route::apiResource('distribution_logs','DistributionLogController')->only(['index']);
        Route::get('distribution/user','DistributionLogController@user');
        Route::get('distribution/link','DistributionLogController@link');

        // 积分订单
        Route::get('/integral_order','IntegralController@get_orders'); // 获取积分订单列表
        Route::get('/integral_order/get_order_info/{id}','IntegralController@get_order_info'); // 查看积分订单信息

        // 用户收货地址
        Route::resource('addresses',Http\Controllers\App\AddressController::class);
        Route::put('/addresses/default/set','AddressController@set_default'); // 设置默认地址
        Route::get('/addresses/default/get','AddressController@get_default'); // 获取默认地址
        // 全国省市区地址获取
        Route::get('/areas','AreaController@areas');
    });
});